#include<stdio.h>
#include<string.h>
char a[1000];    //被除数
int b[1000];    //除数
int c[1000];    //商
int d[1000];    //余数
int can(int last,int len)
{
    if(d[last+len] !=0 ) return 1;
    for(int i = len-1; i>=0;i--)
    {
        //printf("d=%d %d\n",d[last+i],b[i]);
        if(d[last+i] > b[i]) 
        {
            //printf("dsa");
            return 1;
        }
        if(d[last+i] < b[i]) 
        {
            return 0;
            //printf("dsa");
        }
    }
    return 1;
}
int main()
{
    freopen("in.txt","r",stdin);
    memset(a,0,sizeof a);
    memset(b,0,sizeof b);
    memset(c,0,sizeof c);
    memset(d,0,sizeof d);
    char s1[1000];
    char s2[1000];
    scanf("%s",s1);
    scanf("%s",s2);
    int m = strlen(s1);
    int n = strlen(s2);
    for(int i = 0; i < m; i++) a[i] = s1[m-i-1] - '0';
    for(int i = 0; i < n; i++) b[i] = s2[n-i-1] - '0';
    //开始考虑除法
    for(int i = 0; i < m; i++) d[i] = a[i];
    for(int i = m-n; i>=0;i--)
    {
        while (can(i,n))
        {
            //printf("i=%d\n",i);
            for(int j = 0; j < n;j++)
            {
                d[i+j] = d[i+j] - b[j];
                if(d[i+j] < 0)
                {
                    d[i+j+1]-=1;
                    d[i+j]+=10;
                }
            }
            c[i]++;
        }
    }

    int i = 999;
    while(d[i] == 0) i--;
    while(i >=0 ) 
    {
        printf("%d",c[i]);
        i--;
    }
    printf("\n");
    i = 999;
    while (c[i] == 0) i--;
    while (i >= 0 ) printf("%d",c[i--]);
}